package com.bj58.ecdata.mailreport.db;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.apache.log4j.Logger;

public class JdbcUitl {
	private static Logger logger = Logger.getLogger(JdbcUitl.class);
	
    public static void closeConnection(Connection conn) {
        if(conn == null)
            return;
        try{
            conn.close();
        }catch(SQLException ex) {
            logger.debug("Could not close JDBC Connection", ex);
        }catch(Throwable ex) {
            logger.debug("Unexpected exception on closing JDBC Connection", ex);
        }
    }

    public static void closeStatement(Statement stmt)
    {
        if(stmt == null)
            return;
        try{
        	stmt.close();
        }catch(SQLException ex) {
            logger.debug("Could not close JDBC Connection", ex);
        }catch(Throwable ex) {
            logger.debug("Unexpected exception on closing JDBC Connection", ex);
        }
    }

    public static void closeResultSet(ResultSet rs)
    {
        if(rs == null)
            return;
        try{
        	rs.close();
        }catch(SQLException ex) {
            logger.debug("Could not close JDBC Connection", ex);
        }catch(Throwable ex) {
            logger.debug("Unexpected exception on closing JDBC Connection", ex);
        }
    }

}
